package com.libertas.begin;

import com.libertas.begin.R;
import com.libertas.jump.MenuKeepLoginJump;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.view.View.OnClickListener;

public class LoginActivity extends Activity {

	/** Called when the activity is first created. */
	private EditText txtUserName;
	private EditText txtPassword;
	private Button btnLogin;
	private Button btnCancel;

	    /** Called when the activity is first created. */
	    @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.login);
	        
	        txtUserName=(EditText)this.findViewById(R.id.txtUname);
	        txtPassword=(EditText)this.findViewById(R.id.txtPwd);
	        btnLogin=(Button)this.findViewById(R.id.btnLogin);
	        btnCancel=(Button)this.findViewById(R.id.btnCancel);
	        btnLogin.setOnClickListener(new OnClickListener(){

				public void onClick(View v) {
					// TODO Auto-generated method stub
					String username = txtUserName.getText().toString();
					String password = txtPassword.getText().toString();
					if(username.equals("nick") && password.equals("nick")){
				        Toast.makeText(LoginActivity.this, "Login Successful",Toast.LENGTH_LONG).show();
				        HomeLandSecurity.setUsername(username);
				        HomeLandSecurity.setPassword(password);
				        HomeLandSecurity.setJumpTable(MenuKeepLoginJump.getInstance());
				        LoginActivity.this.finish();
				       } else{
				        Toast.makeText(LoginActivity.this, "Invalid Login",Toast.LENGTH_LONG).show();
				       }
				}});     
	        btnCancel.setOnClickListener(new OnClickListener(){
	        	public void onClick(View v){
	        		LoginActivity.this.finish();
	        	}
	        });
	    }

}
